<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<body>
    <script>
        var fileUpload = document.createElement("input");
        fileUpload.type = "file";
        document.body.appendChild(fileUpload);
        fileUpload.addEventListener("change", function () {
            console.log(this.files[0]);
            var fileReader = new FileReader();
            fileReader.readAsDataURL(this.files[0]);
            fileReader.onload = function () {
                console.log(fileReader)
                var img = new Image();
                img.src = fileReader.result;
                fileUpload.parentElement.append(img);
            }
        })
    </script>
</body>

</html>